<%@page import="com.yh.vo.UserVO"%>
<%@page import="com.yh.vo.ZhanfengVO"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="/admin/head.jsp"></jsp:include>
</head>
<body>
	<jsp:include page="/admin/header.jsp"></jsp:include>
	<jsp:include page="/admin/left-menu.jsp"></jsp:include>
	<jsp:include page="/admin/footer.jsp"></jsp:include>

	<!--中间-->
	<section>
		<nav aria-label="breadcrumb">
			<ol class="breadcrumb">
				<li class="breadcrumb-item">管理首页</li>
				<li class="breadcrumb-item">系统中心</li>
				<li class="breadcrumb-item active">用户管理</li>
			</ol>
		</nav>

		<form class="form-inline">
			<div class="form-group mx-sm-1 mb-2">
				<label class="sr-only">新闻类别：</label> <select class="form-control">
					<option value="">全部</option>
				</select>
			</div>
			<div class="form-group mx-sm-1 mb-2">
				<label class="sr-only">关键字：</label> <input name="key" type="text"
					class="form-control" placeholder="搜索关键字">
			</div>
			<button type="submit" class="btn btn-primary mb-2">
				<i class="fa fa-search"></i>
			</button>
			<a href="admin/user-add-form.jsp"
				class="btn btn-success ml-auto mr-2"><i class="fa fa-plus"></i></a>
			<div class="form-group mx-sm-1 mb-2">
				<label class="sr-only">数量：</label> <select name="pageSize"
					class="form-control">
					<option value="5" selected="selected">每页5条</option>
					<option value="10">每页10条</option>
					<option value="20">每页20条</option>
					<option value="50">每页50条</option>
				</select>
			</div>
		</form>
		<div class="ml-2 mr-2">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th scope="col">#</th>
						<th scope="col">用户名称</th>
						<th scope="col">用户年龄</th>
						<th scope="col">用户性别</th>
						<th scope="col">用户注册时间</th>
						<th scope="col">用户角色名称</th>
						<th scope="col">操作</th>
					</tr>
				</thead>
				<%
					List<UserVO> list = (List<UserVO>) request.getAttribute("list");
					for (int i = 0; i < list.size(); i++) {
						UserVO vo = list.get(i);
				%>
				<tbody>
					<tr>
						<th scope="row"><%=i + 1%></th>
						<td><%=vo.getZfName()%></td>
						<td><%=vo.getZfAge()%></td>
						<td><%=vo.getZfSex()%></td>
						<td><%=vo.getZfTime()%></td>
						<td><%=vo.getZfRole()%></td>
						<td>
							<div class="dropdown">
								<button
									class="btn btn-outline-primary btn-block dropdown-toggle"
									type="button" data-toggle="dropdown">操作</button>
								<div class="dropdown-menu dropdown-menu-right">
									<a class="dropdown-item"
										href="admin/user-look.let?userId=<%=vo.getZfId()%>">查看</a> <a
										class="dropdown-item"
										href="admin/user-update-form.let?userId=<%=vo.getZfId()%>">修改</a>
									<a class="dropdown-item _delete"
										href="admin/user-delete.let?userId=<%=vo.getZfId()%>">删除</a>
								</div>
							</div>
						</td>
					</tr>
				</tbody>
				<%
					}
				%>
			</table>
		</div>

		<%-- 分页 --%>
		<nav aria-label="Page navigation example">
			<ul class="pagination justify-content-center">
				<li class="page-item"><a class="page-link"
					href="admin/user-page-key.let?index=1&key=<%=request.getAttribute("key")%>&pageSize=<%=request.getAttribute("pageSize")%>"
					aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
				</a></li>
				<%
					int pages = (int) request.getAttribute("pages");
					int p = (int) request.getAttribute("p");
					for (int i = 1; i <= pages; i++) {
				%>
				<li class="page-item <%=p == i ? "active" : ""%>"><a
					class="page-link"
					href="admin/user-page-key.let?index=<%=i%>&key=<%=request.getAttribute("key")%>&pageSize=<%=request.getAttribute("pageSize")%>"><%=i%></a></li>
				<%
					}
				%>
				<%--<li class="page-item"><a class="page-link" href="admin/user-page.let?index=<%=(1-1)*5%>">1</a></li>
    				<li class="page-item"><a class="page-link" href="admin/user-page.let?index=<%=(2-1)*5%>">2</a></li>
    				<li class="page-item"><a class="page-link" href="admin/user-page.let?index=<%=(3-1)*5%>">3</a></li>
    				 --%>
				<li class="page-item"><a class="page-link"
					href="admin/user-page-key.let?index=<%=pages%>&key=<%=request.getAttribute("key")%>&pageSize=<%=request.getAttribute("pageSize")%>"
					aria-label="Next"> <span aria-hidden="true">&raquo;</span>
				</a></li>
			</ul>
		</nav>
	</section>

	<div class="modal fade" id="confirmDialog" tabindex="-1">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title" id="exampleModalLabel">确认对话框</h5>
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body">您确定要删除这条记录吗？</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-secondary"
						data-dismiss="modal">取消</button>
					<a href="#" class="btn btn-primary">确定</a>
				</div>
			</div>
		</div>
	</div>

</body>

</html>
<script type="text/javascript">
	var confirmDialog = $("#confirmDialog");
	$("._delete").on("click", function() {
		confirmDialog.find("a:last").attr("href", $(this).attr("href"));
		confirmDialog.modal("show");
		return false;
	});
</script>